package cn.edu.swufe.surverpark.struts2.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.edu.swufe.surverpark.model.Page;
import cn.edu.swufe.surverpark.model.Question;
import cn.edu.swufe.surverpark.struts2.service.SurveyService;

/**
 *@author 陈龙 E-mail:529914446@qq.com
 *@version创建时间:2015年4月30日下午8:40:45
 *类说明
 */
@Controller
@Scope("prototype")
public class QuestionAction extends BaseAction<Question> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3355813922424916347L;
	
	private Integer sid;
	private Integer pid;
	private Integer qid;
	
	@Resource
	private SurveyService surveyService;
	public Integer getSid() {
		return sid;
	}
	public void setSid(Integer sid) {
		this.sid = sid;
	}
	public Integer getPid() {
		return pid;
	}
	public void setPid(Integer pid) {
		this.pid = pid;
	}
	
	
	public String toSelectQuestionType(){
		return "selectQuestionTypePage";
	}
	
	public String toDesignQuestionPage(){
		return ""+model.getQuestionType();
	}
	public String saveOrUpdateQuestion(){
		Page page = new Page();
		page.setId(pid);
		model.setPage(page);
		surveyService.saveOrUpdateQuestion(model);
		return "designSurveyAction";
	}
	
	public String deleteQuestion(){
		surveyService.deleteQuestion(qid);
		return "designSurveyAction";
	}
	public Integer getQid() {
		return qid;
	}
	public void setQid(Integer qid) {
		this.qid = qid;
	}
	public String editQuestion(){
		this.model = surveyService.getQuestion(qid);
		return ""+model.getQuestionType();
	}
}

